﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Web.AdminPage
{
    public partial class FrmCall_msgEdit : WebCommon
    {
        public Model.view_call_msg model = new Model.view_call_msg();

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!Page.IsPostBack)
            {
                if (Request.QueryString["Id"] != null)
                {
                    if (Request.QueryString["Id"].Trim().Length > 0)
                    {
                        GetModel(Convert.ToInt32(Request.QueryString["Id"]));
                    }
                }

            }
        }
        public void GetModel(int Id)
        {
            Model.tb_call_msg data = Common.SqlExption.GetList<Model.tb_call_msg>().FirstOrDefault(c => c.Id.Equals(Id)&&c.order_number.Equals(string.Empty));

           

            if (data != null)
            {
            

                model = new Model.view_call_msg()
                {
                    client_id = data.client_id,
                    contents = data.contents,
                    create_time = data.create_time,
                    Id = data.Id,
                    server_id = data.server_id,
                    order_number = data.order_number,
                    cient = Common.SqlExption.GetList<Model.tb_user>().FirstOrDefault(c => c.Id.Equals(data.client_id)).name,
                   
                     call_msg=data.call_msg
                };
            }
            else
            {
                model.Id = 0;
              
                model.create_time = DateTime.Now;
             
            }



        }
    }
}
